{
	_marker = createmarkerLocal [format ["%1_marker", _x], getPos _x];
	format ["%1_marker", _x] setMarkerSizeLocal [0.5,0.5];
	format ["%1_marker", _x] setMarkerTypeLocal "hd_flag";
	format ["%1_marker", _x] setMarkerColorLocal "ColorRed";
	format ["%1_marker", _x] setMarkerShapelocal "ICON";
} foreach BTC_main_city;

"BTC_city_clear" addPublicVariableEventHandler BTC_m_fnc_PVEH;
"BTC_m_PVEH" addPublicVariableEventHandler BTC_m_fnc_PVEH;
"BTC_sm_PVEH" addPublicVariableEventHandler BTC_sm_fnc_PVEH;
"BTC_data_to_pass" addPublicVariableEventHandler BTC_console_execute;
"BTC_s_sitreps" addPublicVariableEventHandler BTC_m_read_sitreps;

[] spawn
{
	waitUntil {!isNull player};
	waitUntil {player == player};
	player setVariable ["BIS_noCoreConversations", true];
	enableSentences false;
	[] spawn
	{
		waitUntil {!isNil "BTC_server_initialized"};
		{
			if (_x getVariable "BTC_city_status" == 1) then {format ["%1_marker", _x] setMarkerColorLocal "ColorGreen";};
		} foreach BTC_main_city;
		_allveh = vehicles + BTC_fob_placed;
		{
			if (!isNil {_x getVariable "BTC_mobile_west"}) then
			{
				_x addAction [("<t color=""#12F905"">") + ("Dismantle FOB") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[_flag],BTC_dismantle_fob], 8, true, true, "", "true"];
				_marker = createmarkerLocal [(_x getVariable "BTC_mobile_west"), getPos _x];
				(_x getVariable "BTC_mobile_west") setMarkerSizeLocal [0.5,0.5];
				(_x getVariable "BTC_mobile_west") setMarkerTypeLocal "hd_flag";
				(_x getVariable "BTC_mobile_west") setMarkerTextLocal (_x getVariable "BTC_mobile_west");
				(_x getVariable "BTC_mobile_west") setMarkerColorLocal "ColorBlue";
				(_x getVariable "BTC_mobile_west") setMarkerShapelocal "ICON";			
			};
		} foreach _allveh;
		if (BTC_sm_assigned && !isNil "BTC_sm_PVEH") then
		{
			_sm = [0,BTC_sm_PVEH] spawn BTC_sm_fnc_PVEH;
		};
		_time = time + 10;
		waitUntil {!isNil "BTC_jip_client" || time > _time};
		if (!isNil "BTC_jip_client") then 
		{
			BTC_jip_move = false;
			_dlg = createDialog "BTC_jip_dialog";
			waitUntil {dialog};
			waitUntil {!dialog};
			if (BTC_jip_move) then
			{
				_pos = BTC_jip_client select 0;
				_gear = BTC_jip_client select 1;
				titleText ["Moving to last saved position", "BLACK OUT"];
				sleep 3;
				titleText ["Moving to last saved position", "BLACK FADED"];
				player setPos _pos;
				_g = [player,_gear] spawn BTC_set_gear;
				BTC_gear = _gear;
				titleText ["Moving to last saved position", "BLACK IN"];
			};
		};
	};

	//Player actions
	setTerrainGrid 50;
	[] spawn BTC_m_actions_resp;
	[] spawn {while {true} do {sleep 2;if (count (nearestObjects [(getpos BTC_m_obj_1), ["LandVehicle","Air"], 10]) > 0) then {private ["_veh"];_veh = (nearestObjects [(getpos BTC_m_obj_1), ["LandVehicle","Air"], 10]) select 0;_veh setDamage 0;_veh setFuel 1;_veh setVehicleAmmo 1;hintSilent "Auto maintenance complete!";};};};
	BTC_m_obj addAction [("<t color=""#12F905"">") + ("Maintenance vehicle") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],BTC_maintenance_veh], 8, true, true, "", "count (nearestObjects [position player, [""LandVehicle"",""Air""], 10]) > 0"];
	BTC_m_obj addAction [("<t color=""#12F905"">") + ("Repair wreck") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],BTC_repair_wreck], 8, true, true, "", "count (nearestObjects [position player, [""LandVehicle"",""Air""], 10]) > 0"];
	BTC_m_c_obj addAction [("<t color=""#12F905"">") + ("Open construction menu") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],BTC_m_c_menu], 8, true, true, "", "true"];//player distance (_target modelToWorld [0,-1,0]) < 1
	BTC_AI_pilot addAction [("<t color=""#12F905"">") + ("Recruit") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],{[BTC_AI_pilot] join (group player);}], 8, true, true, "", "true"];
	BTC_flag addAction [("<t color=""#12F905"">") + ("Respawn dialog") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],BTC_r_create_dialog_mobile], 8, true, true, "", "true"];
	if (rank player == "CAPTAIN") then {BTC_flag addAction [("<t color=""#00ffe9"">") + ("Save Session") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],{BTC_to_server = [3];publicVariableServer "BTC_to_server";}],-11,false,false,"","true"];};
	if (BTC_p_rally == 1) then
	{
		BTC_flag addAction [("<t color=""#12F905"">") + ("Move to rally point") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],BTC_move_to_rally_point], 7, true, true, "", "BTC_rally_point_deployed"];
		//if (rank player == "CAPTAIN") then {BTC_rally_point addaction [("<t color=""#27EE1F"">") + ("Pick up rally point") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],BTC_action_rally_point],0,false,false,"","!isNil ""BTC_rally_point_deployed"""];};
		BTC_rally_point addaction [("<t color=""#27EE1F"">") + ("Pick up rally point") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],BTC_action_rally_point],-8,false,false,"","BTC_rally_point_deployed"];
		if (BTC_rally_point_deployed) then {"BTC_rally_point" setMarkerPos getpos BTC_rally_point;"BTC_rally_point" setMarkerSize [0.5,0.5];"BTC_rally_point" setMarkerText "Rally Point";};
	};
	switch (BTC_def_recr) do {case 0:{};case 1:{if (rank player == "CAPTAIN") then {BTC_obj_recr addAction [("<t color=""#ED2744"">") + ("Recrutiment") + "</t>","=BTC=_addAction.sqf",[[],BTC_action_recruitment],7,false,false,"","true"];};};case 2:{if (rank player == "CAPTAIN" || rank player == "LIEUTENANT") then {BTC_obj_recr addAction [("<t color=""#ED2744"">") + ("Recrutiment") + "</t>","=BTC=_addAction.sqf",[[],BTC_action_recruitment],7,false,false,"","true"];};};};
	//VAS
	BTC_VAS_box addAction [("<t color=""#00ffe9"">") + ("Load VAS profile") + "</t>","=BTC=_revive\=BTC=_addAction.sqf",[[],BTC_main_load_VAS], 7, true, true, "", "true"];
	player addEventHandler ["Respawn", {[] spawn BTC_m_actions_resp;}];
	//Tag
	[] spawn 
	{
		while {true} do
		{
			if (vehicle player == player) then {call BTC_create_tag;} else {if (!BTC_Hud_Cond) then {call BTC_create_veh_info_hud};};
			sleep 0.5;
		};
	};
	//tracking system
	if (BTC_p_track_sys == 1) then {_sys = [] spawn BTC_tracking_sys;};
	//Intro
	if (BTC_debug == 0) then {[] spawn BTC_intro;};
	
	if (BTC_debug == 1) then {player allowDamage false;onMapSingleClick "vehicle player setpos [_pos select 0,_pos select 1,0]";BTC_marker_debug_cond = true;_marker = [] spawn BTC_marker_debug;};
};

/*
Rendi montabili:
"Land_Cargo_Patrol_V3_F"

-----------------------------------

Costruibili:
,"Wall_F"
*/